/**
 * 登录拦截
 */

$.ajax({
	type: "GET",
	url: ajaxUrl("checkRootLogin"),
	async: false,
	success: function(result) {
		// console.log(result);
		if (result.code === 400) {
			location.href = "login.html"
		}
	}
})

$(function(){

	// 退出登录
	$(".login_out_bot").on("click", function() {
		if (confirm("确定要退出登录吗?")) {
			$.ajax({
				type: "GET",
				url: ajaxUrl("employeeLogout"),
				success: function(result) {
					if (result.code === 200) {
						location.href = "login.html"
					}
				}
			})
		}
	})





	var navLi = $('.navs li')
	navLi.on('click',function(){
		$(this).find('ul').slideToggle();
	});
});

/**
 * 根据接口名称返回拼接后的接口地址
 * @param {string} url 接口名称
 */
function ajaxUrl(urlName) {
    return "/api/v1.0/" + urlName
}